jQuery.noConflict(); 

jQuery(document).ready(function() {

	// Focus username field in loginForm
	jQuery("form#loginForm input[name=username]").focus();

	// Tooltip for Highscore Points
	jQuery("table#highscore td.detailedpoints").cluetip({splitTitle: '|'});

	init_bulitable();
	window.setTimeout("init_bulitable()",500);
	window.setTimeout("init_bulitable()",1000);
	window.setTimeout("init_bulitable()",2000);
	window.setTimeout("init_bulitable()",5000);
});

function getTooltip(verein) {
	tip = verein[0]+". "+verein[1] + "|";
	tip += "Punkte: " + verein[8] + "|";
	tip += "Tore: " + verein[6] + " (" + verein[7] + ")|" ;
	tip += "Spiele: " + verein[2];
	tip += " (S: " + verein[3] + ", ";
	tip += "U: " + verein[4] + ", ";
	tip += "N: " + verein[5] + ")";
	return tip;
}
function appendVerein(verein) {
	// console.log("appendVerein() verein: ", verein);
	
	id = "bt" + verein[0];
	name = verein[1];
	tip = getTooltip(verein);
	icon = TIPPSPIEL.base_url + "resources/bundesliga-icons/" + name.replace(/ /g, "_") + ".gif";
	tmpl = "<li><img title=\"" + tip + "\" id=\"" + id + "\" src=\"" + icon + "\" alt=\"" + name + "\"/></li>";
	jQuery("div#buliTabelle ul").append(tmpl);
}

function init_bulitable() {
	// console.log("init_bulitable()", TIPPSPIEL.bulitable);
	
	if (typeof(SCM_ST_ARRAY) != "undefined" && !TIPPSPIEL.bulitable) {
		TIPPSPIEL.bulitable = true;

		// Array('1','NAME','32','20','5','7','51:29','22','65')
		var i = 0;
		while (SCM_ST_ARRAY[i] != null) {
			
			if (SCM_ST_ARRAY[i][1].lastIndexOf("gladbach") != -1) SCM_ST_ARRAY[i][1] = "Bor. Moenchengladbach";
			if (SCM_ST_ARRAY[i][1].lastIndexOf("Bayern") != -1) SCM_ST_ARRAY[i][1] = "Bayern Muenchen";
			if (SCM_ST_ARRAY[i][1].lastIndexOf("1. FC K") != -1) SCM_ST_ARRAY[i][1] = "1. FC Koeln";
			if (SCM_ST_ARRAY[i][1].lastIndexOf("1. FC N") != -1) SCM_ST_ARRAY[i][1] = "1. FC Nuernberg";

			appendVerein(SCM_ST_ARRAY[i]);
			i++;
		}
		jQuery("div#buliTabelle ul li img").cluetip({splitTitle: '|'});
		
		jQuery("#sportalTable").remove();
	} // if (typeof(SCM_ST_ARRAY) != "undefined")
	
};


function initPodcasts(url, swfUrl) {

	var flashvars = {
			file: url,
			playlist: 'over',
			quality:'false',
			backcolor:'009900',
			frontcolor:'FFFFFF',
			lightcolor:'004F00',
			screencolor:'003300'
	};
	swfobject.embedSWF(swfUrl+"player.swf", "podcastPlayer", "600", "300", "9", swfUrl+"expressInstall.swf", flashvars);
}



// prevent console.log error in IE
if (!window.console || !console.firebug) {
	var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml", "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];
	window.console = {};
	for (var i = 0; i < names.length; ++i)
		window.console[names[i]] = function() {}
}